Repository navigation
Scripts: Preserve static and dynamic imports of script modules - #87098
Draft
luisherranz wants to merge 12 commits into
Draft
luisherranz wants to merge 12 commits into
luisherranz wants to merge 12 commits into
Conversation
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. 📦 Bundle sizeSize Change: 0 B Total Size: 8.68 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. a navigation superseded by the traversal discharges to idle in
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Preserve static
importdeclarations and dynamicimport()calls for external script modules inwp-scriptsbuilds, even when the same source file uses both forms for the same module.Why?
Webpack’s external configuration can turn a static import into a dynamic one or make an on-demand import static. That changes when the browser loads the dependency.
How?
Use webpack’s
module-importexternal type and keep dynamic imports separate from static imports of the same module. The generated asset file still lists each dependency once, with static taking precedence. The dependency extraction plugin now requires webpack 5.95 or later;wp-scriptsalready meets that requirement.Testing Instructions
@wordpress/a11yboth statically and withimport(), usingwp-scripts build --experimental-modules. Verify that the emitted JavaScript contains both forms and the asset file lists the dependency once, as static.wp-scripts start --experimental-modules. Edit the source to trigger a rebuild and verify that both import forms remain.Use of AI Tools
100% of the code, tests, and comments in this PR were autonomously generated by AI and reviewed by @luisherranz before the PR was opened.